package com.cbn.ibcp.jishiting.gs.cms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cbn.ibcp.common.annotation.DataSource;
import com.cbn.ibcp.common.enums.DataSourceType;
import com.cbn.ibcp.jishiting.gs.cms.domain.Org;
import com.cbn.ibcp.jishiting.gs.cms.mapper.OrgMapper;
import com.cbn.ibcp.jishiting.gs.cms.service.IOrgService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class OrgServiceImpl implements IOrgService {

    private final OrgMapper orgMapper;

    @DataSource(DataSourceType.gs_cms)
    @Override
    public Org selectByOrgCode(String orgCode) {
        LambdaQueryWrapper<Org> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Org::getCode, orgCode);
        return orgMapper.selectOne(lambdaQueryWrapper);
    }

    @DataSource(DataSourceType.gs_cms)
    @Override
    public List<Org> selectList() {
        LambdaQueryWrapper<Org> queryWrapper = new LambdaQueryWrapper<>();
        return orgMapper.selectList(queryWrapper);
    }
}
